#include "Framework/StableHeaders.h"
#include "Graphics/VertexBufferBinding.h"
#include "Graphics/IDeviceBufferManager.h"
#include "Graphics/IDeviceVertexBuffer.h"



namespace tyro
{
	namespace Graphics
	{


		const Graphics::IDeviceVertexBufferSharedPtr& VertexBufferBinding::GetBuffer( USHORT_16 index ) const
		{
			VertexBufferBindingMap::const_iterator i = bindingMap.find(index);
			if (i == bindingMap.end())
			{
			}
			return i->second;
		}

		bool VertexBufferBinding::IsBufferBound( UINT_32 index ) const
		{
			return bindingMap.find(index) != bindingMap.end();
		}

		void VertexBufferBinding::SetBinding( USHORT_16 index, const IDeviceVertexBufferSharedPtr& buffer )
		{
			bindingMap[index] = buffer;
			highIndex = max(highIndex, (USHORT_16)(index+1));
		}

		VertexBufferBinding::VertexBufferBinding()
			:	highIndex(0)
		{

		}

		size_t VertexBufferBinding::GetBufferCount( void ) const
		{
			return bindingMap.size();
		}

	}
}